package team.future.joke.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;

import com.mongodb.WriteResult;

import team.future.joke.entity.JokeCollector;

/**
 * Title: JokePageDaoImpl.java<br>
 * Description: <br>
 * Copyright (c) 未来工作室版权所有 2015    <br>
 * Create DateTime: 2015年9月2日 上午10:57:34 <br>
 * @author futurezhu
*/
@Service("jokeCollectorDao")
public class JokeCollectorDaoImpl extends BaseMongoDaoImpl<JokeCollector> {

	@Autowired
	private MongoOperations mongoTemplate;

	@Override
	public JokeCollector getObject(Query query) {
		return mongoTemplate.findOne(query, JokeCollector.class);
	}

	@Override
	public int updateObject(Query query, Update update) {
		WriteResult res = mongoTemplate.updateFirst(query, update, JokeCollector.class);
		return res.getN();
	}

	@Override
	public void insertObject(JokeCollector jokeCollector) {
		mongoTemplate.insert(jokeCollector);
	}

}
